{% extends "public/base.html" %}
{% block main %}
<div class="admin-content">
    <div class="am-cf am-padding">
        <div class="am-fl am-cf">
            <a href="{{url(nav[0]['url'])}}"><strong class="am-text-primary am-text-lg">{{nav[0]['title']}}</strong></a>
            {% if nav[1]['title'] is not empty %} /<a href="{{url(nav[1]['url'])}}" style="color:#333"><small>{{nav[1]['title']}}</small></a>{% endif %}
        </div>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <a href="{{url('menu/new')}}" class="am-btn am-btn-success"><span class="am-icon-plus"></span> 新增</a>
                    <button type="button" class="am-btn am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                </div>
            </div>
        </div>
    </div>
    <br>
    <div class="am-g">
        <form action="{{url('menu/search')}}" method="get">
            <div class="am-u-sm-12 am-u-md-3">
                <div class="am-form-group">
                    <select name="pid" data-am-selected="{btnSize: ''}">
                        <option value="">全部菜单</option>
                        {% for option in item %}
                        <option value="{{option.id}}" {% if option.id== pid %}selected {% endif %}>{{option.title}}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
                <div class="am-input-group am-datepicker-date"
                     data-am-datepicker="{format: 'yyyy-mm-dd', viewMode: 'days'}">
                    <input name="startDate" type="text" class="am-form-field" placeholder="开始日期" value="{{this.request.getQuery('startDate')}}">
                <span class="am-input-group-btn am-datepicker-add-on">
                    <button class="am-btn am-btn-default" type="button"><span class="am-icon-calendar"></span></button>
                </span>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
                <div class="am-input-group am-datepicker-date"
                     data-am-datepicker="{format: 'yyyy-mm-dd', viewMode: 'days'}">
                    <input name="endDate" type="text" class="am-form-field" placeholder="结束日期" value="{{this.request.getQuery('endDate')}}">
                <span class="am-input-group-btn am-datepicker-add-on">
                    <button class="am-btn am-btn-default" type="button"><span class="am-icon-calendar"></span></button>
                </span>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-3">
                <div class="am-input-group">
                    <input name="title" type="text" class="am-form-field" placeholder="菜单标题" value="{{this.request.getQuery('title')}}">
                <span class="am-input-group-btn">
                    <button class="am-btn am-btn-default" type="submit">搜索</button>
                </span>
                </div>
            </div>
        </form>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12">
            <form class="am-form">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <th class="table-check">
                            <input type="checkbox" />
                        </th>
                        <th>ID</th>
                        <th>菜单标题</th>
                        <th>url</th>
                        <th>分组菜单</th>
                        <th>是否隐藏</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for menu in page.items %}
                    <tr>
                        <td>
                            <input type="checkbox" />
                        </td>
                        <td>{{menu.id}}</td>
                        <td><a href="{{url('menu/index?pid='~menu.id)}}">{{menu.title}}</a></td>
                        <td>{{menu.url}}</td>
                        <td>{{menu.is_group?"是":"否"}}</td>
                        <td>{{menu.is_hide?"是":"否"}}</td>
                        <td>
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <a href="{{url('menu/edit?id='~menu.id)}}">
                                        <button type="button" class="am-btn am-btn-default  am-btn-xs am-text-primary">
                                            <span class="am-icon-pencil-square-o"></span>
                                            编辑
                                        </button>
                                    </a>
                                    <a href="javascript:;" class="delete">
                                        <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only">
                                            <span class="am-icon-trash-o"></span>
                                            删除
                                        </button>
                                    </a>
                                </div>
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
                <div class="am-cf">
                    共{{ page.total_pages }}页、{{page.total_items}}条记录
                    <br>
                    {% if page.total_pages > 1 %}
                    <div class="am-fr">
                        <ul class="am-pagination">
                            <li>
                                {{ link_to("menu/index", 'First') }}
                            </li>
                            <li {% if page.current == 1 %}class="am-disabled"{% endif %}>
                                {{ link_to("menu/index?page=" ~ page.before, 'Prev') }}
                            </li>
                            <?php 
                                $i=1; 
                                while ($i <= $page->total_pages) {
                            if ($page->current == $i) {
                            echo '<li class="am-active"><a href="index?page='.$i.'">'.$i.'</a></li>';
                            }else{
                            echo '<li><a href="index?page='.$i.'">'.$i.'</a></li>';
                            }
                            $i++;
                            }
                            ?>
                            <li {% if page.current == page.total_pages %}class="am-disabled"{% endif %}>
                                {{ link_to("menu/index?page=" ~ page.next, 'Next') }}
                            </li>
                            <li>
                                {{ link_to("menu/index?page=" ~ page.last, 'Last') }}
                            </li>
                        </ul>
                    </div>
                    {% endif %}
                </div>
                <hr />
                <p>注：.....</p>
            </form>
        </div>
    </div>
</div>
{% endblock %}
{% block javascript %}
<script language="javascript">
$(document).ready(function () {

});
</script>
{% endblock %}
